package com.zhengshang.api.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.zhengshang.common.enums.UserStatus;
import com.zhengshang.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhengshang.api.mapper.AppBannerMapper;
import com.zhengshang.api.domain.AppBanner;
import com.zhengshang.api.service.IAppBannerService;

/**
 * APP端banner图Service业务层处理
 * 
 * @author zhengshang
 * @date 2021-03-09
 */
@Service
public class AppBannerServiceImpl implements IAppBannerService 
{
    @Autowired
    private AppBannerMapper appBannerMapper;

    /**
     * 查询APP端banner图
     * 
     * @param bannerId APP端banner图ID
     * @return APP端banner图
     */
    @Override
    public AppBanner selectAppBannerById(Long bannerId)
    {
        return appBannerMapper.selectAppBannerById(bannerId);
    }

    /**
     * 查询APP端banner图列表
     * 
     * @param appBanner APP端banner图
     * @return APP端banner图
     */
    @Override
    public List<AppBanner> selectAppBannerList(AppBanner appBanner)
    {
        return appBannerMapper.selectAppBannerList(appBanner);
    }

    @Override
    public List<AppBanner> queryAppBannerList(AppBanner appBanner) {
        List<AppBanner> list = appBannerMapper.queryAppBannerList(appBanner);
        return list == null ? new ArrayList<>() : list;
    }

    /**
     * 新增APP端banner图
     * 
     * @param appBanner APP端banner图
     * @return 结果
     */
    @Override
    public int insertAppBanner(AppBanner appBanner)
    {
        appBanner.setDelFlag(UserStatus.OK.getCode());
        appBanner.setCreateTime(DateUtils.getNowDate());
        return appBannerMapper.insertAppBanner(appBanner);
    }

    /**
     * 修改APP端banner图
     * 
     * @param appBanner APP端banner图
     * @return 结果
     */
    @Override
    public int updateAppBanner(AppBanner appBanner)
    {
        appBanner.setUpdateTime(DateUtils.getNowDate());
        return appBannerMapper.updateAppBanner(appBanner);
    }

    /**
     * 批量删除APP端banner图
     * 
     * @param bannerIds 需要删除的APP端banner图ID
     * @return 结果
     */
    @Override
    public int deleteAppBannerByIds(Long[] bannerIds)
    {
        return appBannerMapper.deleteAppBannerByIds(bannerIds);
    }

    /**
     * 删除APP端banner图信息
     * 
     * @param bannerId APP端banner图ID
     * @return 结果
     */
    @Override
    public int deleteAppBannerById(Long bannerId)
    {
        return appBannerMapper.deleteAppBannerById(bannerId);
    }

    @Override
    public int updateAppBannerStatus(AppBanner appBanner) {
        return appBannerMapper.updateAppBanner(appBanner);
    }
}
